package com.example.bilibiliprojectspringboot.mapper;


import com.example.bilibiliprojectspringboot.model.entity.VideoInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VideoMapper {

  @Select("SELECT * FROM video ORDER BY publisher_time DESC")
  List<VideoInfo> selectAllVideoPublisherTimeDesc();

  // 插入一个视频数据
  @Insert("INSERT INTO video(user_id, title,description,thumbnail,url,view_count,barrage_count,like_count,dislike_count,forwarding_count,duration,resolution,size_in_bytes,publisher_time,update_time) VALUES (#{userId}, #{title}, #{description},#{thumbnail},#{url},#{viewCount},#{barrageCount},#{likeCount},#{dislikeCount},#{forwardingCount},#{duration},#{resolution},#{sizeInBytes},#{publisherTime},#{updateTime})")
  @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
  void insertVideoByObject(VideoInfo videoInfo);


}